<template>
  <div class="base-add-on-pagination" v-if="paginationInfo.totalItems">
    <!-- 附加组件分页 -->
    <i18n path="common.base.table.totalCount">
      <span place="count">{{ paginationInfo.totalItems }}</span>
    </i18n>

    <el-pagination
      background 
      @current-change="handlePageJump"
      @size-change="handleSizeChange"
      :page-sizes="defaultTableData.defaultPageSizes"
      :page-size="paginationInfo.pageSize" 
      :current-page="paginationInfo.pageNum" 
      layout="prev, pager, next, sizes"
      :total="paginationInfo.totalItems">
    </el-pagination>
  </div>
</template>
<script>
import { defaultTableData } from '@src/util/table'

export default {
  name: 'BaseAddOnPagination',
  props: {
    paginationInfo: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {
      defaultTableData
    };
  },
  methods: {
    handlePageJump(pageNum) {
      this.$emit('pageJump', pageNum)
    },
    handleSizeChange(pageSize) {
      this.$emit('sizeChange', pageSize)
    }
  },
};
</script>
<style lang="scss" scoped>
.base-add-on-pagination {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  ::v-deep .el-pagination {
    padding: 2px 0;
    .el-pagination__sizes {
      margin: 0;
      .el-select {
        .el-input {
          margin: 0;
        }
      }
    }
  }
}
</style>